var Store = function () {   //公共类
    var XStore = {
        converter: function (store, index) {  //转换器方法
            for (var i = 0; store.length; i++) {
                if (store[i] || false) {
                    if (store[i][0] || false) {
                        if (store[i][0] == index) {
                            return store[i][1];
                        }
                    } else {
                        return "";
                    }

                } else {
                    return "";
                }

            }
            return "";
        }
    }
    return XStore;
};
$(function () {
//学部数据
    $(".add-discipline-college").combobox({
        valueField: 'ico_id',
        textField: 'ico_name',
        panelHeight: "auto",
        editable: false, //不允许手动输入
        data: app_data.info.college("LIST")
    });
    
    //专业数据
    $(".add-class-discipline").combobox({
        valueField: 'id_id',
        textField: 'id_name_year',
        panelHeight: "auto",
        editable: false, //不允许手动输入
        data: app_data.info.discipline("LIST")
    });
    
    //班级号
    $(".add-class-nummber").combobox({
        valueField: 'id',
        textField: 'name',
        panelHeight: "auto",
        editable: false, //不允许手动输入
        data: [{id: 1, name: '1班'},
            {id: 2, name: '2班'},
            {id: 3, name: '3班'},
            {id: 4, name: '4班'},
            {id: 5, name: '5班'},
            {id: 6, name: '6班'},
            {id: 7, name: '7班'},
            {id: 8, name: '8班'},
            {id: 9, name: '9班'},
            {id: 10, name: '10班'}
        ]
    });
    
    //开设年份
    $(".add-discipline-time").combobox({
        valueField: 'id',
        textField: 'name',
        panelHeight: "auto",
        editable: false, //不允许手动输入
        data: [{id: 2011, name: 2011},
            {id: 2012, name: 2012},
            {id: 2013, name: 2013},
            {id: 2014, name: 2014},
            {id: 2015, name: 2015},
            {id: 2016, name: 2016},
            {id: 2017, name: 2017},
            {id: 2018, name: 2018},
            {id: 2019, name: 2019},
            {id: 2020, name: 2020}]
    });

    //性别
    $(".mc_number-commbox").combobox({
        valueField: 'id',
        textField: 'name',
        panelHeight: "auto",
        editable: false, //不允许手动输入
        data: [{id: '1', name: '第1学期'},
              {id: '2', name: '第2学期'}]
    });

    $(".curriculum-commbox").combobox({
        url: Think.APP + "Public/curriculumInfo",
        valueField: 'cu_id',
        textField: 'cu_name',
        panelHeight: "auto",
        editable: false, //不允许手动输入
    });

    $(".teacher-commbox").combobox({
        valueField: 'id',
        textField: 'nickname',
        panelHeight: "auto",
        editable: false, //不允许手动输入
        data: app_data.info.teacher("LIST")
    });

     //性别
    $(".student-sex-combobox").combobox({
        valueField: 'id',
        textField: 'name',
        panelHeight: "auto",
        editable: false, //不允许手动输入
        data: [{id: '男', name: '男'},
              {id: '女', name: '女'}]
    });

    $(".start_time_box").datetimebox({
            required: false,
            formatter: function (date) {
                var y = date.getFullYear();
                var m = date.getMonth() + 1;
                var d = date.getDate();
                var hh = date.getHours();
                var mm = date.getMinutes();
                var ss = date.getSeconds();
                return y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d) + ' ' + (hh < 10 ? ('0' + hh) : hh) + ':' + (mm < 10 ? ('0' + mm) : mm) + ':' + (ss < 10 ? ('0' + ss) : ss);
            },
            parser: function (date) { return new Date(Date.parse(date.replace(/-/g, "/"))); },
            onSelect: function (date) { 
                $("#StartDT").val(date);
                var startDate = date;
                var endDate = $('#EndDT').val();
                if ((new Date(startDate)).dateDiff(endDate) > 0) {
                    var y = date.getFullYear();
                    var m = date.getMonth() + 1;
                    var d = date.getDate();
                    var hh = date.getHours();
                    var mm = date.getMinutes();
                    var ss = date.getSeconds();
                    var dateStr =  y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d) + ' ' + (hh < 10 ? ('0' + hh) : hh) + ':' + (mm < 10 ? ('0' + mm) : mm) + ':' + (ss < 10 ? ('0' + ss) : ss);
                    $("#EndDT").datetimebox('setValue', dateStr);
                }
            }
        });
});


